//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Copyright 2007 CORE Solutions Limited
// All rights reserved.
// PROPRIETARY AND CONFIDENTIAL INFORMATION.
// Use is subject to license terms.
//
// FUNCTION ID      :   ACCESS_TEAM
// AUTHOR           :   Jerry Chen 
// DATE CREATE      :   2007/10/26
// DESCRIPTION      :   a MAINTENANCE ACTION file for the function, ACCESS_TEAM
//                  :   
//                  :   
//                  :   
//
// MODIFICATION HISTORY:
// DATE         AUTHOR          VERSION NO.         COMMENT
// -----------  --------------  ------------------  -------------------
// 2007/10/26   Jerry Chen      1.0                 source is generated.
//
//
//
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

package com.erp.app.setup.accessTeamMaster.web;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import com.erp.app.common.ProjectConstants;
import com.erp.app.setup.accessTeamMaster.pk.AccessTeamHdrPk;
import com.erp.app.setup.accessTeamMaster.schema.AccessTeamHdrSchema;
import com.erp.app.setup.accessTeamMaster.vo.AccessTeamHdrVo;
import com.erp.app.util.web.WebUtil;
import com.erp.framework.controller.action.SimpleMaintStyleActionTemplate;
import com.erp.framework.model.pk.SimpleBasePk;
import com.erp.framework.util.logger.Logger;
import com.erp.framework.util.user.User;

/**
* A <strong>Maintenance Action</strong> is an adapter between the contents of an incoming
* HTTP request and the corresponding business logic that should be executed to
* process this request.  The controller (ActionServlet) will select an
* appropriate Action for each request.
* The main purpose for this action class is to handle the user document maintenance events
* from the web browsers.
*
* @author          Jerry Chen 
* @version 1.0     2007/10/26
* @since           FrameWork 1.0
*
*/
public class AccessTeamMaintenanceAction extends SimpleMaintStyleActionTemplate {

	////////////////////////////////////////////////////////////////////////////////
	// CONSTANTS DEFINITION
	////////////////////////////////////////////////////////////////////////////////

	public static final int TAB_IDX_HDR = -1;

	public static final String HDR = "Hdr";

	public static final String ACTION_CHANGE_FOLDER_HDR = ACTION_CHANGE_FOLDER + HDR;




	////////////////////////////////////////////////////////////////////////////////
	// GLOBAL VARIABLES DEFINITION
	////////////////////////////////////////////////////////////////////////////////



	////////////////////////////////////////////////////////////////////////////////
	// LOGICAL AND BUSINESS METHODS
	////////////////////////////////////////////////////////////////////////////////


	////////////////////////////////////////////////////////////////////////////////
	// END OF LOGICAL AND BUSINESS METHODS
	////////////////////////////////////////////////////////////////////////////////


	////////////////////////////////////////////////////////////////////////////////
	// OVERRIDES PARENT'S OPTIONAL METHODS
	////////////////////////////////////////////////////////////////////////////////

	protected void beforeCreate(ActionMapping mapping, ActionForm formIn,
		HttpServletRequest request, HttpServletResponse response, ActionErrors errors) {

		HttpSession session = request.getSession(false);
		AccessTeamMaintenanceForm form = (AccessTeamMaintenanceForm) formIn;
		String action = form.getPageEvent();
		ActionForward actionForward = new ActionForward(mapping.getInput());
		User editingUser = (User) session.getAttribute(ProjectConstants.SESSION_USER);

		try {
			form.setCompanyCode(WebUtil.getAppropriateCompanyCode(session, ProjectConstants.SP_SHARE_ACCESS_TEAM));
			form.setHdrStatus(ProjectConstants.GENERIC_ACTIVE);
			form.setTs(new AccessTeamHdrSchema());
			form.setTsName("com.erp.app.setup.accessTeamMaster.schema.AccessTeamHdrSchema");
			form.setAccessTeamCode(ProjectConstants.WEB_TO_BE_GENERATED);
		} catch (Exception e) {
			Logger.logExceptions(this, e);
		}
	}

	public String getSessionMaintStatus() {

		return getSessionSimpleMaintStatus();
	}

	public String getSessionMaintPk() {

		return getSessionSimpleMaintPk();
	}

	public String getStrutsId() {

		return getFunctionId();
	}

	public String getSimpleFormReadOnlySessionName(){

		//TODO: Add the following line to ProjectWebConstants.java
		//public static final String SESSION_ACCESS_TEAM_FORM_READ_ONLY_SESSION_NAME = "SESSION_ACCESS_TEAM_FORM_READ_ONLY_SESSION_NAME";
		return ProjectConstants.SESSION_ACCESS_TEAM_FORM_READ_ONLY_SESSION_NAME;
	}

	public String getSimpleFormReadOnlyCallerSessionName(){

		//TODO: Add the following line to ProjectWebConstants.java
		//public static final String SESSION_ACCESS_TEAM_FORM_READ_ONLY_CALLER_SESSION_NAME = "SESSION_ACCESS_TEAM_FORM_READ_ONLY_CALLER_SESSION_NAME";
		return ProjectConstants.SESSION_ACCESS_TEAM_FORM_READ_ONLY_CALLER_SESSION_NAME;
	}

	protected String getSimpleSrchMenuId() {

		//TODO: Add the following line to ProjectMenuConstants.java
		//public static final String MOD_ACCESS_TEAM = "MOD_ACCESS_TEAM";
		return ProjectConstants.MOD_ACCESS_TEAM;
	}

	////////////////////////////////////////////////////////////////////////////////
	// END OF OPTIONAL METHODS
	////////////////////////////////////////////////////////////////////////////////


	////////////////////////////////////////////////////////////////////////////////
	// IMPLEMENTS PARENT'S ABSTRACT METHODS
	////////////////////////////////////////////////////////////////////////////////

	protected String getModuleName(ActionMapping mapping, ActionForm formIn,
		HttpServletRequest request,HttpServletResponse response) {

		//TODO: Add the following line to ProjectMenuConstants.java
		//public static final String MOD_ACCESS_TEAM = "MOD_ACCESS_TEAM";
		return ProjectConstants.MOD_ACCESS_TEAM;
	}

	protected String getFunctionId() {

		//struts-config xxxxx.do
		return "accessTeamMaintenance.do";
	}

	protected Class getMasterFormClass() {

		//the corresponding form class
		return AccessTeamMaintenanceForm.class;
	}

	protected Class getMasterVOClass() {

		//corresponding master vo class
		return AccessTeamHdrVo.class;
	}

	protected String getMasterFormSessionName() {

		return "accessTeamMaintenanceForm";
	}

	protected Class[] getChildRowClass() {

		Class[] childRowClass = new Class[] {

		};

		return childRowClass;
	}

	protected String[] getFolderChildIdxMapping() {

		String[] folderChildIdx = new String[1];


		return folderChildIdx;
	}

	protected SimpleBasePk getPk(ActionForm formIn, HttpServletRequest request) {

		AccessTeamMaintenanceForm form = (AccessTeamMaintenanceForm) formIn;
		AccessTeamHdrPk pk = null;
		HttpSession session = request.getSession(false);

		//TODO: Add the following line to ProjectSecurityConstants.java
		//public static final String SP_SHARE_ACCESS_TEAM = "SP_SHARE_ACCESS_TEAM";
		String companyCode = WebUtil.getAppropriateCompanyCode(session, ProjectConstants.SP_SHARE_ACCESS_TEAM);

//		edit the following with appropriate form field names
		pk = new AccessTeamHdrPk(companyCode, form.getAccessTeamCode());
		return pk;
	}

	protected void setFormType(ActionMapping mapping, ActionForm formIn, HttpServletRequest request,
		HttpServletResponse response, ActionErrors errors){

		AccessTeamMaintenanceForm form = (AccessTeamMaintenanceForm) formIn;
		form.setFormType(ProjectConstants.FORM_TYPE_MAINT);
	}

	////////////////////////////////////////////////////////////////////////////////
	// END OF ABSTRACT METHODS
	////////////////////////////////////////////////////////////////////////////////
}
